/* 
 * File:   SmartLaplacianIQ.h
 * Author: boyan
 *
 * Created on June 12, 2009, 1:05 PM
 */

#ifndef _SMARTLAPLACIANIQ_H
#define	_SMARTLAPLACIANIQ_H

#include <InstructionQueue.hpp>
#include <ShapeQualityMetric.hpp>
#include <QualityAssessor.hpp>
#include <TerminationCriterion.hpp>
#include <LaplacianSmoother.hpp>
#include <SmartLaplacianSmoother.hpp>
#include <MsqError.hpp>

class SmartLaplacianIQ : public Mesquite::InstructionQueue
{
private:
    Mesquite::ShapeQualityMetric* inverseMeanRatio;
    Mesquite::SmartLaplacianSmoother* lapl1;
    Mesquite::QualityAssessor* mQA;
    Mesquite::TerminationCriterion* mTerm;

public:

    //! Constructor sets the instructions in the queue.

    SmartLaplacianIQ()
    {
        Mesquite::MsqError err;
        // creates a mean ratio quality metric ...
        inverseMeanRatio = new Mesquite::IdealWeightInverseMeanRatio(err);

        // creates the laplacian smoother  procedures
        lapl1 = new Mesquite::SmartLaplacianSmoother(NULL, err);
        mQA = new Mesquite::QualityAssessor
                (inverseMeanRatio, Mesquite::QualityAssessor::MAXIMUM, err);

        //**************Set stopping criterion****************
        mTerm = new Mesquite::TerminationCriterion();
        mTerm->add_criterion_type_with_int
                (Mesquite::TerminationCriterion::NUMBER_OF_ITERATES, 10, err);

        lapl1->set_outer_termination_criterion(mTerm);

        // adds 1 pass of pass1
        this->add_quality_assessor(mQA, err);
        MSQ_CHKERR(err);
        this->set_master_quality_improver(lapl1, err);
        MSQ_CHKERR(err);
        this->add_quality_assessor(mQA, err);
        MSQ_CHKERR(err);
    }

    void disable_printing_results()
    {
        mQA->disable_printing_results();
    }

    //! Destructor must delete the objects inserted in the queue.

    virtual ~SmartLaplacianIQ()
    {
        delete inverseMeanRatio;
        delete lapl1;
        delete mQA;
        delete mTerm;
    }

};



#endif	/* _SMARTLAPLACIANIQ_H */

